<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
<form class="layui-form" id="form1">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">名字</label>
            <div class="layui-input-inline">
                <input type="hidden" name="uuid" th:value="${data.getUuid()}">
                <input type="text" name="name" th:value="${data.getName()}" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">订单ID</label>
            <div class="layui-input-inline">
                <input type="tel" name="orderid" th:value="${data.getOrderid()}" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline">
            <select name="memo" lay-verify="required" lay-search="" id="memo">
                <option value="">直接选择或搜索选择</option>
                <option value="layer">layer</option>
                <option value="form">form</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">创建日期</label>
        <div class="layui-input-inline">
            <input type="text" name="createdata" th:value="${data.getCreatedata()}" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item"></div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" onclick="save();" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
        </div>
    </div>
</form>
<script th:inline="javascript">
    var $;
    layui.use(['laydate','form','jquery'], function(){
        $=layui.jquery;
        var form = layui.form
            ,laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#date'
        });

        //下拉框选中
        var memo=[[${data.memo}]]
        var select = 'dd[lay-value=' + memo + ']';
        $('#memo').siblings("div.layui-form-select").find('dl').find(select).click();
    });

    function save(){
        var data=$('#form1').serialize();
        $.ajax({
            type:"post",url:"/courseorder/update",
            data:data,
            error:function () {
                layer.alert("操作失败，请您稍后再试！");
            },
            success:function (msg) {
                if(msg=='true'){
                    layer.msg("操作成功", {
                        icon: 1,//成功的表情
                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        parent.layer.closeAll();
                        //修改成功后刷新父界面
                        window.parent.location.reload();
                    });
                }else{
                    layer.alert("操作失败，请您稍后重试！");
                }
            }
        });
    }
</script>

</body>
</html>